

""" PGame World

A pgame-level body, handles game-wide events.
"""

#Soya imports
import soya, soya.sdlconst

#python imports
import sys, os

#custom imports


class pgameWorld(soya.World):
    def __init__(self, parent=None):
        soya.World.__init__(self, parent)
        
    def begin_round(self):
        soya.World.begin_round(self)
        
        #process events
        for event in soya.process_event():
            self.check_quit(event)
    
    def check_quit(self, event):
        """If the given event is a quit event, exits."""
        if event[0] == soya.sdlconst.KEYDOWN:
            if event[1] == soya.sdlconst.K_q:
                soya.MAIN_LOOP.stop()
            elif event[1] == soya.sdlconst.K_ESCAPE:
                soya.MAIN_LOOP.stop()
    
    def advance_time(self, proportion):
        soya.World.advance_time(self, proportion)